<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>naisi</title>
		<style type="text/css">
			body{
				text-align: center;
			}
		</style>
	</head>
	<body>
		<p>
			整数1：<input type="text" id="one"/>
		</p>
		<p>
			整数2：<input type="text" id="two"/>
		</p>
		<p>
			<button onclick="col(1)">相加</button>
			<button onclick="col(2)">相减</button>
			<button onclick="col(3)">相乘</button>
			<button onclick="col(4)">相除</button>
		</p>
		<p>
			结果: <input type="text" id="eace"/>
		</p>
		<script>
			function col(n){
			var one = document.querySelector("#one").value;
			var two = document.querySelector("#two").value;
			var eace = document.querySelector("#eace").value;
			var result = 0;
			if( n == 1){
				result=Number(one)+Number(two);
			}
			if( n == 2){
				result=Number(one)-Number(two);
			}
			if( n == 3){
				result=Number(one)*Number(two);
			}
			if( n == 4){
				result=Number(one)/Number(two);
				if(Number(two)==0){
					alert("0不可以做除数！")
				}
			}
			document.querySelector("#eace").value = result;
		}
		</script>
	</body>
</html>
